
Partial Class TableE
    Inherits System.Web.UI.Page

    Private Const Q As String = Chr(34)

    Private moServer As SQLAutoDocLib.Server = Nothing
    Private moDatabase As SQLAutoDocLib.Database = Nothing

    Dim msSID As String
    Dim msDID As String
    Dim mlSort As SQLAutoDocLib.SProc_Factory.SORT

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack = False Then
            msSID = Request.QueryString("S")
            msDID = Request.QueryString("D")
            Dim sSort As String = Request.QueryString("SORT")

            If IsNumeric(sSort) Then
                mlSort = sSort
            Else
                mlSort = SQLAutoDocLib.SProc_Factory.SORT.DATE_DESC
            End If

            hidSID.Value = msSID
            hidDID.Value = msDID
            hidSort.Value = mlSort

            ARefresh.HRef = "SQTableE.aspx?S=" & msSID & "&D=" & msDID & "&SORT=" & mlSort
        Else
            msSID = hidSID.Value
            msDID = hidDID.Value
            mlSort = hidSort.Value
        End If

        moServer = New SQLAutoDocLib.Server(msSID)
        moServer.Load()

        moDatabase = New SQLAutoDocLib.Database(msDID)
        moDatabase.Load()
    End Sub

    Protected Sub ShowTableList()
        Dim oTableReporter As New SQLAutoDocLib.Rpt_Tables
        oTableReporter.ShowTableList(moDatabase.ID, moDatabase.RevID, mlSort)
    End Sub

    Protected Function FormLabel() As String
        Dim oFactory As New SQLAutoDocLib.ScanHistory_Factory
        Dim sCurrentScan As String = ""
        Dim sLastScan As String = ""
        oFactory.GetTimeOfLastScan(moDatabase.ID, SQLAutoDocLib.ScanSchedule.Type.SchemaScan, "SQLAutoDocLib.Table", sCurrentScan, sLastScan)

        Dim sValue As String = "View Table List for " & moDatabase.Name & " last scan completed " & sLastScan

        If sCurrentScan > "" Then
            sValue = " scan in progress started " & sCurrentScan
        End If

        Return sValue
    End Function

    Protected Function ScanMode() As String
        Return "Tables"
    End Function

    Protected Function EditMode() As String
        Return "Table"
    End Function

    Protected Function ServerID() As String
        Return moServer.ID
    End Function

    Protected Function DatabaseID() As String
        Return moDatabase.ID
    End Function
End Class
